﻿Imports System.Data.Linq
Imports System.Linq

Public Class AgentRepository
    Private dc As New TanNamChinhDataContext

    Public Sub New()
        dc = GeneralClassDAL.dc
    End Sub

    'Public Function SelectAllRecord() As IQueryable(Of tblAgent)
    '    Dim query = From p In dc.tblAgents
    '                Select p

    '    Return query
    'End Function

    'Public Function SelectRecordById(ByVal id As Integer) As tblAgent
    '    Dim company = dc.tblAgents.SingleOrDefault(Function(p As tblAgent) p.ID_Agent = id)
    '    Return company
    'End Function

    'Public Function SelectRecordByName(ByVal Name As String) As tblAgent
    '    Dim query = dc.tblAgents.SingleOrDefault(Function(p As tblAgent) p.Name = Name) ' And p.IsActive = True)
    '    Return query
    'End Function

    'Public Sub Insert(ByVal obj As tblAgent)
    '    dc.tblAgents.InsertOnSubmit(obj)
    '    dc.SubmitChanges()
    'End Sub

    'Public Sub Update(ByVal obj As tblAgent)
    '    dc.Refresh(RefreshMode.KeepChanges, obj)
    '    dc.SubmitChanges(ConflictMode.ContinueOnConflict)
    'End Sub

    ' ''' <summary>
    ' ''' Xử lý thêm dòng emmpty trước danh mục (chưa xong)
    ' ''' </summary>
    ' ''' <returns></returns>
    ' ''' <remarks></remarks>
    'Public Function SelectCustomAllRecord() As IQueryable
    '    Dim empty As tblAgent() = {New tblAgent With {.ID_Agent = 0, .Name = "", .Address = "", .Tel = "", .Fax = ""}}
    '    Dim query = (From p In empty Select p).Union(From q In dc.tblAgents Select q)
    '    'Dim query = From p In companies
    '    '            Select p

    '    Return query
    'End Function
End Class
